package com.kehutong.auth.action;

import com.kehutong.auth.entity.AccountOperateLog;
import com.kehutong.common.util.Token;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.logger.Logger;
import org.coraframework.logger.LoggerFactory;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.Result;
import org.coraframework.orm.jdbc.JdbcSession;
import org.coraframework.orm.jdbc.Page;
import org.coraframework.util.Objects;

/**
 * 账号操作日志
 * @author: liukunlong
 * @date: 2021-07-27 15:36
 */
@MvcAction
@ReqMapping("/kht-bin/account/operate/log")
public class AccountOperateLogAction {
    private static final Logger logger = LoggerFactory.getLogger(AccountOperateLogAction.class);

    @Inject
    private JdbcSession jdbcSession;
    /**
     * 用户操作日志列表
     * @param jsonObject
     * @return
     * @throws Exception
     */
    @ReqMapping("/page")
    public Object getAccountOperateLogList(Token token, JSONObject jsonObject) throws Exception {
        if (Objects.isNull(token)) {
            return Result.unlogin();
        }
        Page<AccountOperateLog> page = jdbcSession.findPage(AccountOperateLog.class)
                .eq("deleted", false)
                .eq(jsonObject, "id","accountNo")
                .order("createTime", "desc")
                .page(jsonObject)
                .exe();
        return page;
    }
}
